class ShoppingcartMap {
  final Map<int, Shoppingcart> map;

  ShoppingcartMap(this.map);
  factory ShoppingcartMap.fromJson(List<dynamic> itemlist) {
    Map<int, Shoppingcart> map = new Map();
    for (var item in itemlist) {
      map[Shoppingcart.fromJson(item).id] = Shoppingcart.fromJson(item);
    }
    return ShoppingcartMap(map);
  }
}

class Shoppingcart {
  int id;
  int commodityId;
  String name;
  String intro;
  double money;
  int commodityNumber;
  final String imgurl1;
  bool selection;

  Shoppingcart({
    this.id,
    this.commodityId,
    this.name,
    this.intro,
    this.money,
    this.imgurl1,
    this.commodityNumber,
    this.selection,
  });

  factory Shoppingcart.fromJson(dynamic item) {
    return Shoppingcart(
      commodityId: item['commodityId'],
      name: item['name'],
      intro: item['intro'],
      money: item['money'],
      imgurl1: item['imgurl1'],
      id: item['id'],
      commodityNumber: item['commodityNumber'],
      selection: false,
    );
  }
}
